# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=cmsmap
pkgver=8.59dd0e2
pkgrel=10
epoch=1
pkgdesc='A python open source Content Management System scanner that automates the process of detecting security flaws of the most popular CMSs.'
groups=('blackarch' 'blackarch-scanner' 'blackarch-automation'
        'blackarch-webapp' 'blackarch-exploitation')
arch=('any')
url='https://www.dionach.com/blog/cmsmap-%E2%80%93-a-simple-cms-vulnerability-scanner'
license=('GPL3')
depends=('python' 'exploitdb')
makedepends=('git' 'python-setuptools')
source=("$pkgname::git+https://github.com/Dionach/CMSmap.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd $pkgname

  sed 's|wp_plugins_small = data/wp_plugins_small.txt|wp_plugins_small = data/wp_plugins.txt|g' \
    -i cmsmap/cmsmap.conf
  sed 's|edbtype = apt|edbtype = GIT|g' -i cmsmap/cmsmap.conf
  sed 's|edbpath = /usr/share/exploitdb/|edbpath = /opt/exploitdb/|g' \
    -i cmsmap/cmsmap.conf
}

build() {
  cd $pkgname

  python setup.py build
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/opt/"

  python setup.py install --root="$pkgdir" --prefix=/usr --skip-build

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname" README.md DISCLAIMER.txt
  install -Dm 644 LICENSE.txt "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  cd "$pkgdir/opt"

  git clone https://github.com/offensive-security/exploit-database exploitdb
}

